{% macro gen_table(demands) %}
    <table id="demand-info-table"
           class="table table-bordered table-hover table-condensed table-striped">
        <thead>
        <tr>
            <th>用户id</th>
            <th style="width: 9%;">手机号</th>
            <th>用户昵称</th>
            <th>需求分类</th>
            <th>故障</th>
            <th>类型</th>
            <th>环境</th>
            <th>大小</th>
            <th>颜色</th>
            <th>间距</th>
            <th>省份</th>
            <th>城市</th>
            <th>预算</th>
            <th>成功人数</th>
            <th>标签</th>
            <th>来源</th>
            <th>状态</th>
            <th>客服</th>
            <th>发布次数</th>
            <th>创建时间</th>
            <th>发布时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {% for demand in demands %}
            <tr>
                {% if demand.owner %}
                    <td>
                        <a
                                href="{{ url_for('op_bp.user_info', user_id=demand.owner.id) }}"
                                target="_blank"
                        >{{ demand.owner.id }}</a>
                    </td>
                    <td>{{ demand.owner.mobile | encrypt }}</td>
                    <td>{{ demand.owner.nickname }}</td>
                {% else %}
                    <td></td>
                    <td></td>
                    <td></td>
                {% endif %}
                <td>{{ demand.cate_display }}</td>
                <td>{{ demand.malf_display }}</td>
                <td>{{ demand.type_display }}</td>
                <td>{{ demand.surr_display }}</td>
                <td>{{ demand.size }}平方米</td>
                <td>{{ demand.color_display }}</td>
                <td>{{ demand.span }}</td>
                <td>{{ demand.prov }}</td>
                <td>{{ demand.city }}</td>
                <td>{{ demand.budget }}</td>
                <td>{{ demand.partic_success_cnt }}</td>
                <td>{{ demand.tag_display }}</td>
                <td>{{ demand.source }}</td>
                <td>{{ demand.status_display }}</td>
                <td>{{ demand.admin_display }}</td>
                <td>{{ demand.published_count }}</td>
                <td>{{ demand.created_datetime }}</td>
                <td>{{ demand.published_datetime }}</td>
                <td style="white-space: nowrap; overflow: hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis;">
                    <a
                            class="btn btn-xs btn-primary btn-group"
                            href="{{ url_for('op_bp.demand_info', demand_id=demand.id) }}"
                            name="demand-info"
                            target="_blank"
                    >编辑</a>
                    {% if demand.status not in (200, 410) and not demand.is_locked and demand.published_count < 2 %}
                        <a
                                class="btn btn-xs btn-success btn-group"
                                href="{{ url_for('op_bp.publish_demand', demand_id=demand.id) }}"
                                name="demand-publish"
                                target="_blank"
                        >{% if demand.published_count == 1 %}重新发布{% else %}
                            首发{% endif %}</a>
                    {% endif %}
                    <a href="javascript:void(0);"
                       class="show_remark_modal btn btn-info btn-xs"
                       data-admin-remark="{{ demand.admin_remark }}"
                       data-remark="{{ demand.remark }}"
                       data-nickname="{{ demand.owner.nickname }}"
                    >
                        备注
                    </a>
                    <a href="{{ url_for('auth_bp.publish_demand_logs', demand_id=demand.id) }}"
                       class="btn btn-warning btn-xs"
                    >
                        日志
                    </a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endmacro %}
